package connect_severTest;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;




import java.io.IOException;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import connet_sever.ConnectServer;
import connet_sever.WaitingInfo;


public class ConnectServerTest {
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		System.out.println("Before class");
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		System.out.println("After class");
	}

	@Before
	public void setUp() throws Exception {
		System.out.println("Before");
	}
	@Test
	public void testSend(){
		ConnectServer c=ConnectServer.create_instance();
		
		Thread thread = new Thread(new WaitingInfo(c));
		thread.start();
		
		try {
			c.send(3, 0);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String r=(String)c.recieve();
		assertThat(r,is("a"));
		c.close();
	}

	@After
	public void tearDown() throws Exception {
		System.out.println("After");
	}
}
